import path from "path";
import { app } from "electron";

export const sleep = (wait) => {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      resolve();
    }, wait);
  });
};

export const getResourcesPath = () => {
  if (app.isPackaged) {
    return process.resourcesPath;
  } else {
    return path.join(app.getAppPath(), "src", "other-res");
  }
};

export const getAdbProgram = () => {
  const resourcesPath = getResourcesPath();
  const adbToolPath = path.join(resourcesPath, "adbtool");
  const isMac = process.platform === "darwin"; // 获取当前运行平台
  let adbProgram;
  if (isMac) {
    adbProgram = path.join(adbToolPath, "mac", "adb");
  } else {
    adbProgram = path.join(adbToolPath, "win", "adb.exe");
  }
  return adbProgram;
};
